﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" src="gpu.js"></script>
    <script src="cpu.js" type="text/javascript"></script>
    <script src="key.js" type="text/javascript"></script>
    <script src="timer.js" type="text/javascript"></script>
    <script src="mmu.js" type="text/javascript"></script>
    <script src="gameboy.js" type="text/javascript"></script>
    <script src="fileread.js" type="text/javascript"></script>
</head>
<body style="background-color:Black;color:White;">
    <div style="float: left">
        <div>
            <canvas width="160px" height="144px" id="screen">no canvas</canvas>
        </div>
        <div>
            <input type="button" value="run" onclick="run()" /><input type="button" value="reset" onclick="reset();" /></div>
            <div><input type="text" id="opct" onkeypress="if(event.keyCode==13) run();"/></div>
    </div>
    <div style="margin-left: 10px;float:left">
        <table border="1" cellpadding="5" cellspacing="0">
            <tr><th colspan="4">CPU</th></tr>
            <tr><td>A</td><td id="cpua"></td><td>OP count</td><td id="opcount"></td></tr>
            <tr><td>B</td><td id="cpub"></td><td>OP</td><td id="op"></td></tr>
            <tr><td>C</td><td id="cpuc"></td><td>flag</td><td id="cpuflag"></td></tr>
            <tr><td>D</td><td id="cpud"></td><td>PC</td><td id="cpupc"></td></tr>
            <tr><td>E</td><td id="cpue"></td><td>SP</td><td id="cpusp"></td></tr>
            <tr><td>H</td><td id="cpuh"></td><td>T</td><td id="cput"></td></tr>
            <tr><td>L</td><td id="cpul"></td><td>ime</td><td id="cpuime"></td></tr>
            <tr><td>FZ</td><td id="cpufz"></td><td>FC</td><td id="cpufc"></td></tr>
        </table>
    </div>
    <div style="float:left;margin-left: 10px;">
        <table border="1" cellpadding="5" cellspacing="0">
            <tr><th colspan="2">GPU</th></tr>
            <tr><td>curline</td><td id="curline"></td></tr>
            <tr><td>linemode</td><td id="linemode"></td></tr>
            <tr><td>modeclocks</td><td id="modeclock"></td></tr>
            <tr><td>yscrl</td><td id="yscrl"></td></tr>
            <tr><td>xscrl</td><td id="xscrl"></td></tr>
        </table>
    </div>
    <div style="margin-left: 10px;float:left">
        <table border="1" cellpadding="5" cellspacing="0">
            <tr><th colspan="4">Register</th></tr>
            <tr><td>div</td><td id="div"></td><td>IF</td><td id="if"></td></tr>
            <tr><td>tima</td><td id="tima"></td><td>IE</td><td id="ie"></td></tr>
            <tr><td>tma</td><td id="tma"></td><td>main clock</td><td id="mainclock"></td></tr>
            <tr><td>tac</td><td id="tac"></td><td>sub clock</td><td id="subclock"></td></tr>
        </table>
    </div>
</body>
</html>
<script type="text/javascript" src="fdebugger.js"></script>
<script type="text/javascript">
    var runner;
    var lastc = 0;
    var db = document.getElementById("debug");
    window.onkeydown = key.keydown;
    window.onkeyup = key.keyup;
    //gpu.setScreenDevice(document.getElementById('screen'));
    reset();
    function run() {
        cpu._stop = 0;
        c = parseInt(document.getElementById("opct").value);
        if (lastc > c) { reset(); opc = 0; clearInterval(runner);enterpress = false; }
        lastc = c;
        if (c == 0) c = -1;
        runner = setInterval(start, 16);
    }
    fdebugger.start();
</script>

